package com.zjitc;


import com.zjitc.config.JavaConfigDemo1;
import com.zjitc.config.JavaConfigDemo2;
import com.zjitc.obj.Teacher;
import com.zjitc.obj.User;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;


/**
 * Create by IntelliJ IDEA
 *
 * @author: jsonor
 * @date-Time: 2018/3/6 15:48
 * @description:
 */
public class App3 {

  public static void main(String[] args) {
    //之前要读取xml文件现在编写java
    //理论上是单例对象
//    ApplicationContext context=new AnnotationConfigApplicationContext(JavaConfigDemo1.class);
    ApplicationContext context=new AnnotationConfigApplicationContext(JavaConfigDemo2.class);
    User u1 = context.getBean("user",User.class);
    User u2 = context.getBean("user",User.class);
    Teacher t1=context.getBean("teacher",Teacher.class);

    if(u1.equals(u2)){
      System.out.println("equals");
    }
    System.out.println(t1);
    System.out.println(u1);
  }



}
